import {defineStore} from 'pinia';

const store = {
    id: "user",
    state(){
        return {
            userInfo: {}
        }
    },

    getters: {

    },

    actions: {
        setUser(userInfo) {
            this.userInfo = userInfo;
        },

        async getUserInfo() {
            let {code, data} = await Http.get("/user/info");
            if(code == 200) {
                return data.sysUser
            }
            return {};
        },

        async modifyPwd(oldPwd, newPwd) {
            let {code, data} = await Http.post("/user-modify-pwd", {oldPwd, newPwd});
            if(code != 200) {
                return false;
            }
            return data;
        }
    }
}

export default defineStore(store)
